package com.rd.student.jiaji.class1.wangyufang.day0801;

//实现一个方法 avg, 以数组为参数, 求数组中所有元素的平均值
public class ArrayTest4 {
    public static void main(String[] args) {
        int[] array = new int[]{1, 23, 23, 12, 45, 56, 67};
        avg(array);
    }

    public static void avg(int[] arr) {
        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            sum = sum + arr[i];
        }
        double average = sum / (double) arr.length;
        System.out.println(average);
    }
}
